/**
 * 中间件 token验证拦截
 */
 import {
  getToken,
  getJson
} from '../plugins/import'
 import { Request, Response, NextFunction } from 'express'
 import { noTokenVerificationPath } from '../config/setting'
 export default (req: Request, res: Response, next: NextFunction) => {
  const path = req.url 
  const token = req.headers.authorization
  const tokenId = getToken(token)
  if (tokenId === 'null' && noTokenVerificationPath.indexOf(<never>path) === -1) {
    res.json(getJson('false', 500, 'token校验失败'))
    return 
  }
  next()
 }